package at.fhooe.mc.master.clc.client.handler;

import at.fhooe.mc.master.clc.client.MetricsVisualizationEventBus;
import at.fhooe.mc.master.clc.client.presenter.AbstractGraphPresenter;

import com.mvp4g.client.annotation.EventHandler;
import com.mvp4g.client.event.BaseEventHandler;

@EventHandler
public class PresenterHandler extends BaseEventHandler<MetricsVisualizationEventBus>
{
	private int graphKey = 0;
	
	public void onCreateGraph(
			Class<? extends AbstractGraphPresenter<?, ?>> graphClass,
			String jsonData,
			String axisTitle,
			String graphTitle)
	{
		AbstractGraphPresenter<?, ?> presenter = (AbstractGraphPresenter<?, ?>) eventBus.addHandler(graphClass, false);
		presenter.setKey(graphKey++);
		presenter.setJsonDataTable(jsonData);
		presenter.setTitle(graphTitle);
		presenter.setAxisTitle(axisTitle);
		
		presenter.bind();
	}
	
}
